$(function () {
});
var editor;
//文本编辑器
function kedit(kedit) {
    // var clearDefault=true;//是否有默认文字信息
    editor = KindEditor.create(kedit, {
        width: '1400px',
        height: '600px',
        resizeMode: 0,
        allowPreviewEmoticons: false,
        allowImageUpload: true,//允许上传图片
        allowFileManager: true, //允许对上传图片进行管理
        uploadJson: baseURL+'sys/upload/imgUpload', //上传图片的java代码
        fileManagerJson: baseURL+'/upload/fileManager',
        afterUpload: function () {
            this.sync();
        }, //图片上传后，将上传内容同步到textarea中
        afterBlur: function () {
            this.sync();
        }, //失去焦点时，将上传内容同步到textarea中

        items: [
            'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'cut', 'copy', 'paste',
            'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
            'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
            'superscript', 'clearhtml', 'selectall', '|', 'fullscreen', '/',
            'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
            'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image',
            'table', 'hr', 'emoticons', 'baidumap','media'
        ]
    });
};
var vm = new Vue({
	el:'#rrapp',
	data:{
		btCustomerSummary: {}
	},
	methods: {
		saveOrUpdate: function (event) {
			var url = vm.btCustomerSummary.id == null ? "sys/btcustomersummary/save" : "sys/btcustomersummary/update";
            vm.btCustomerSummary.context = encodeURIComponent($("#activity_detail").val());
			$.ajax({
				type: "POST",
			    url: baseURL + url,
                contentType: "application/json",
			    data: JSON.stringify(vm.btCustomerSummary),
			    success: function(r){
			    	if(r.code === 0){
						alert('操作成功', function(index){

						});
					}else{
						alert(r.msg);
					}
				}
			});
		},

		getInfo: function(){
			$.get(baseURL + "sys/btcustomersummary/info", function(r){
				if(r.btCustomerSummary==null){
                    vm.btCustomerSummary.id=null;
                    vm.btCustomerSummary.context="";
				}else{
                    vm.btCustomerSummary = r.btCustomerSummary;
				}
                var t;
                clearTimeout(t);
                KindEditor.remove('textarea[name="contentDetail"]');
                t = setTimeout(function (){
                    kedit('textarea[name="contentDetail"]');
                }, 500);
            });
		}
	},
    mounted: function () {
        this.getInfo();
    }

});